package cn.stylefeng.guns.modular.business.frequency.cmdriver.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.cmdriver.service.CmDriverService;
import cn.stylefeng.guns.modular.business.frequency.cmdriver.model.param.CmDriverParam;

import javax.annotation.Resource;

/**
 * 通讯录司机表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class CmDriverController {

    @Resource
    private CmDriverService cmDriverService;

    /**
     * 分页查询通讯录司机表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmDriver/page")
    @BusinessLog(title = "通讯录司机表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CmDriverParam cmDriverParam) {
        return new SuccessResponseData(cmDriverService.page(cmDriverParam));
    }

    /**
     * 获取全部通讯录司机表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmDriver/list")
    @BusinessLog(title = "通讯录司机表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CmDriverParam cmDriverParam) {
        return new SuccessResponseData(cmDriverService.list(cmDriverParam));
    }

    /**
     * 查看详情通讯录司机表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmDriver/detail")
    @BusinessLog(title = "通讯录司机表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CmDriverParam.detail.class) CmDriverParam cmDriverParam) {
        return new SuccessResponseData(cmDriverService.detail(cmDriverParam));
    }

    /**
     * 添加通讯录司机表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmDriver/add")
    @BusinessLog(title = "通讯录司机表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CmDriverParam.add.class) CmDriverParam cmDriverParam) {
        cmDriverService.add(cmDriverParam);
        return new SuccessResponseData();
    }

    /**
     * 删除通讯录司机表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmDriver/delete")
    @BusinessLog(title = "通讯录司机表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CmDriverParam.delete.class) CmDriverParam cmDriverParam) {
        cmDriverService.delete(cmDriverParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑通讯录司机表
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmDriver/edit")
    @BusinessLog(title = "通讯录司机表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CmDriverParam.edit.class) CmDriverParam cmDriverParam) {
        cmDriverService.edit(cmDriverParam);
        return new SuccessResponseData();
    }


}
